<#include "/WEB-INF/views/admin/common/layout/__formlayout.html">
<#assign pageCss>
<link rel="stylesheet" href="${ctx}/resource/validationengine/css/validationEngine.jquery.css">
</#assign>
<#assign pageScript>
<script type="text/javascript" src="${ctx}/resource/validationengine/js/jquery.validationEngine-zh_CN.js"></script>
<script type="text/javascript" src="${ctx}/resource/validationengine/js/jquery.validationEngine.js"></script>
<script type="text/javascript">
$(document).ready(function() {
	<#if res??>
		$("#pid").val(${res.pid});
		$("#type").val(${res.type});
		$("#des").text("${res.des}");
	</#if>
	
	$("#frm").validationEngine('attach', {
		promptPosition : 'topLeft',
		scroll : false
	});
	$("#subBtn").click(function() {
		var frm = $("#frm");
		if (frm.validationEngine("validate")) {
			$.ajax({
				type : "POST",
				url : "${ctx}/admin/sys/res/save_update",
				data : frm.serialize(),
				success : function(result) {
					if (result.isSuccess) {
						layer.msg(result.msg, {
							icon : 1,
							time : 1000,
							end : function() {
								//信息提示完成后关闭表单窗口
								var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
								parent.layer.close(index); //再执行关闭  
							}
						});
					} else {
						layer.msg(result.msg, {
							time : 1000,
							icon : 2
						});
					}
				}
			});
		}
	});
});
</script>
</#assign>
<@formlayout>
<div class="row">
	<div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
		<div class="widget am-cf">
			<div class="widget-body am-fr">
				<form class="am-form tpl-form-border-form" id="frm"
					action="${ctx}/admin/sys/res/save">
					<input type="hidden" name="res.id" id="id" value="${res.id!}">
					<div class="am-form-group">
						<label for="name" class="am-u-sm-3 am-form-label">名称 </label>
						<div class="am-u-sm-9">
							<input type="text"
								class="tpl-form-input validate[required,maxSize[50]]" id="name" value="${res.name!}"
								name="res.name" placeholder="请输入资源名称">
						</div>
					</div>
					<div class="am-form-group">
						<label for="pid" class="am-u-sm-3 am-form-label">父类菜单 </label>
						<div class="am-u-sm-9">
							<select name="res.pid" id="pid" class="am-selected-text">
								<option value="">顶级菜单</option>
								<#list menuTreeView as m>
									<option value="${m.id}">${m.name}</option>
								</#list>
							</select>
						</div>
					</div>
					<div class="am-form-group">
						<label for="url" class="am-u-sm-3 am-form-label">地址 </label>
						<div class="am-u-sm-9">
							<input type="text"
								class="tpl-form-input validate[required,maxSize[200]]" value="${res.url!}"
								id="url" name="res.url" placeholder="请输资源地址">
						</div>
					</div>

					<div class="am-form-group">
						<label for="type" class="am-u-sm-3 am-form-label">类型 </label>
						<div class="am-u-sm-9">
							<select name="res.type" id="type" class="am-selected-text">
								<option value="1">菜单</option>
								<option value="2">按钮</option>
							</select>
						</div>
					</div>

					<div class="am-form-group">
						<label for="key" class="am-u-sm-3 am-form-label">KEY </label>
						<div class="am-u-sm-9">
							<input type="text"
								class="tpl-form-input validate[required,maxSize[200]]" id="key" value="${res.key!}"
								name="res.key" placeholder="请输资源Key">
						</div>
					</div>

					<div class="am-form-group">
						<label for="iconCls" class="am-u-sm-3 am-form-label">图标 </label>
						<div class="am-u-sm-9">
							<input type="text" class="tpl-form-input validate[maxSize[200]]" value="${res.iconCls!}"
								id="iconCls" name="res.iconCls" placeholder="请输资源图标">
						</div>
					</div>

					<div class="am-form-group">
						<label for="res" class="am-u-sm-3 am-form-label">排序 </label>
						<div class="am-u-sm-9">
							<input type="text"
								class="tpl-form-input validate[required,custom[integer],maxSize[3]]" value="${res.seq!}"
								id="seq" name="res.seq" placeholder="请输入资源排序号">
						</div>
					</div>

					<div class="am-form-group">
						<label for="des" class="am-u-sm-3 am-form-label">描述</label>
						<div class="am-u-sm-9">
							<textarea class="validate[required,maxSize[25]]" rows="10"
								id="des" name="res.des" placeholder="请输入资源描述信息"></textarea>
						</div>
					</div>

					<div class="am-form-group">
						<div class="am-u-sm-9 am-u-sm-push-3">
							<button type="button"
								class="am-btn am-btn-primary tpl-btn-bg-color-success "
								id="subBtn">提交</button>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>
</@formlayout>

